package demo1

import "fmt"

type Remote interface {
	Power()
	VolumeDown()
	VolumeUp()
	ChannelDown()
	ChannelUp()
}

// 基本版遥控器
type BasicRemote struct {
	Device Device
}

func (b *BasicRemote) Power() {
	fmt.Println("Remote: 开关机")
	if b.Device.IsEnabled() {
		b.Device.Disable()
	} else {
		b.Device.Enable()
	}
}

func (b *BasicRemote) VolumeDown() {
	fmt.Println("Remote: 调小音量")
	b.Device.SetVolume(b.Device.GetVolume() - 10)
}

func (b *BasicRemote) VolumeUp() {
	fmt.Println("Remote: 调大音量")
	b.Device.SetVolume(b.Device.GetVolume() + 10)
}

func (b *BasicRemote) ChannelDown() {
	fmt.Println("Remote: 向下调台")
	b.Device.SetVolume(b.Device.GetChannel() - 1)
}

func (b *BasicRemote) ChannelUp() {
	fmt.Println("Remote: 向上调台")
	b.Device.SetVolume(b.Device.GetChannel() + 1)
}

// 高级版遥控器
type AdvancedRemote struct {
	BasicRemote
}

func (ar AdvancedRemote) mute() {
	fmt.Println("Remote: 静音")
	ar.Device.SetVolume(0)
}
